-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print dependencies in uv pip list. #10886
base: main
Are you sure you want to change the base?
Conversation
This is controlled by the --requires and --required-by flags and only works when the output format is JSON.
As I was doing more research about this, I noticed that pypa/pip#11097 is prior art, where incorporating arbitrary metadata into the output of |
Hi team, wondering if you’ve had a chance to think about if this is the right form factor for exposing this information. Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delay! I think the basic idea looks reasonable, I mostly have a few quibbles about the structure.
#[arg(long, overrides_with("no_requires"))] | ||
pub requires: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the semantics you've implemented this seems like this should also include conflicts_with = "required_by"
.
#[arg(long, overrides_with("requires"), hide = true)] | ||
pub no_requires: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm what's the usecase for having this opt out flag too?
@@ -150,6 +160,47 @@ pub(crate) async fn pip_list( | |||
results | |||
}; | |||
|
|||
let requires_map = if requires || required_by { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to structure this as
let requires_map = requires.then(|| { ... });
let required_by_map = required_by.then(|| { ... });
As-is it's weird to have this shared variable for two conceptually independent results just because they happen to have the same type. It's also not clear to me that these need to be mutually exclusive outputs? (And if that's the case, ignore the note above about the cli conflicts_with)
I'm also wondering about how this fits into our CLI... like |
I guess more broadly it's unclear if we should have |
Summary
This is controlled by the
--requires
and--required-by
flags and only works when the output format is JSON.This addresses part of #4711, but I agree with #4711 (comment) that it belongs in
uv pip list
instead ofuv pip tree
. A few notes about this:--requires
and--required-by
to match theRequires
andRequired-By
fields that appear in the output ofuv pip show
.name
. This leaves the door open to add more fields to each dependency in the future, such as installed version and requested versions.I'm hoping to get some early feedback on this PR to test the temperature of this approach, before I proceed. The remaining work as I see it currently includes:
uv pip tree
instead).Test Plan